package com.woniu.market_stall.web;

import com.github.pagehelper.PageInfo;
import com.woniu.market_stall.result.ResultResponse;
import com.woniu.market_stall.service.AuctionDetailService;
import com.woniu.market_stall.vo.StallAuctionDetailVo;
import com.woniu.market_stall.vo.StallVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("auctionDetail")
public class StallAuctionDetailController {
    @Autowired
    AuctionDetailService auctionDetailService;

    @GetMapping("/list")
    @ApiOperation(value = "本接口是查询按条件分页查询竞拍摊位明细数据的")
    public ResultResponse<PageInfo<StallAuctionDetailVo>> list(
            @ApiParam(value = "当前页的参数") @RequestParam(value = "now", defaultValue = "1") Integer now,
            @ApiParam(value = "页面大小的参数") @RequestParam(value = "size", defaultValue = "3") Integer size,
            @ApiParam(value = "按条件搜索的user名称") @RequestParam(value = "username", defaultValue = "") String username ,
            int stallId) {
        ResultResponse<PageInfo<StallAuctionDetailVo>> result = null;
        try {
            PageInfo<StallAuctionDetailVo> pageInfo = auctionDetailService.queryAuctionDetailByUsername(now, size,username,stallId);
            result = new ResultResponse<>(200, "查询竞拍摊位明细成功!", pageInfo);
        } catch (RuntimeException e) {
            e.printStackTrace();
            result = new ResultResponse<>(201, "查询竞拍摊位明细失败!");
        }
        return result;
    }



}
